package com.example.timeemail.Dao;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

import com.example.timeemail.entity.User;

//个人信息的数据库操作类
public class UserDao {

    private DbHelper helper;

    public UserDao(Context context) {
        //初始化DbHelper帮助类
        helper = new DbHelper(context);
    }

    //增加个人信息
    public long insert(User user){

        //创建数据库操作对象
        SQLiteDatabase db = helper.getWritableDatabase();
        //封装数据
        ContentValues values = new ContentValues();

        values.put("name",user.getName());
        values.put("email",user.getEmail());
        values.put("password",user.getPassword());
        values.put("sex",user.getSex());
        values.put("age",user.getAge());
        values.put("phone",user.getPhone());

        Long id = db.insert("user",null,values);
        db.close();

        return id;
    }


}
